require(['./config'],()=>{
	require(['template','header','footer','utils'],(template)=>{
		class Login{
			constructor(arg) {
			    this.isuser()
			}
			isuser(){
				$('#loginbtn').on('click',()=>{
					this.name=$('#mannger').val(),
					this.pwd=$('#manngerpassword').val()
					console.log(this.name,this.pwd)
					let userList=localStorage.getItem('userList')
					console.log(userList)
					if(userList){
						userList=JSON.parse(userList)
						const isExist=userList.some(user=>{
							// console.log(user.name,user.password)
							
							return user.name===this.name &&user.password===this.pwd
						})
						console.log(isExist)
						if(isExist){
							alert('登录成功')
							utils.setCookie('name',{path:'/'})
						}else{
							alert('用户名或者密码错误请重新登录')
						}
					}else{
						alert('请先注册')
						location.replace('/html/register.html')
					}
				})
			}
		}
		new Login()
	})
})